{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Hello World\n",
        "\n",
        "Watch the full [C# 101 video](https://www.youtube.com/watch?v=KT2VR7m19So&list=PLdo4fOcmZ0oVxKLQCHpiUWun7vlJJvUiN&index=2) for this module.\n",
        "\n",
        "## What do you do with this notebook?\n",
        "\n",
        "This notebook is intended to help you learn the coding language C#. You can:\n",
        "\n",
        "- Work through these notebooks on your own.\n",
        "- Work through them while watching the C# 101 videos.\n",
        "- Use these notebooks as prompts to write your own code in Visual Studio.\n",
        "\n",
        "## What is C#?\n",
        "\n",
        "It's a powerful and widely used programming language that you can use to make websites, games, mobile apps, desktop apps, and more. C# is part of the .NET programming platform, which includes libraries for all those applications. Learn C#, get started, and it'll give you the world.\n",
        "\n",
        "## C#: Hello World\n",
        "\n",
        "Write your first C# program! It outputs a string \"Hello World\" to the console.\n",
        "> Hover your mouse over the following code. On the left side, a little \"play\" icon should show up. Click that and the code will run!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "dotnet_interactive": {
          "language": "csharp"
        }
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Hello World!\r\n"
          ]
        }
      ],
      "source": [
        "Console.WriteLine(\"Hello World!\");"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "`Console.WriteLine` is a method that is used to print a message to a text console. In this case, you specified \"Hello World\" as the output.\n",
        "\n",
        "# Declare and use variables\n",
        "\n",
        "A **variable** is a symbol you can use to run the same code with different values. For example, you can declare a new variable named `aFriend` that you can use with `Console.WriteLine` to output a string. You can declare this variable by using the type `string` or by using the `var` keyword that will automatically figure out the type for you.\n",
        "\n",
        "> Go ahead and run the following code to see the output of **Jayme**.\n",
        ">\n",
        "> Next, change the name in the variable and run it again to see something different."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "dotnet_interactive": {
          "language": "csharp"
        }
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Jayme\r\n"
          ]
        }
      ],
      "source": [
        "var aFriend = \"Jayme\";\n",
        "Console.WriteLine(aFriend);"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Combining Strings\n",
        "\n",
        "You may have noticed that the word \"Hello\" was missing from the last code block. You can fix it by combining multiple string together using `+` to create a new string that it output to the console.\n",
        "\n",
        "> Run the code to write out a friendly welcome!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "dotnet_interactive": {
          "language": "csharp"
        }
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Hello Jayme!\r\n"
          ]
        }
      ],
      "source": [
        "Console.WriteLine(\"Hello \" + aFriend + \"!\");"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# String Interpolation\n",
        "\n",
        "You just used `+` to build a new string from a **variable** and a **constant**. There's a better way to do this by placing the variable between `{`and `}` to tell C# to replace that text with the value of the variable. This is called **string interpolation**. You can then add a `$` before the opening quote to enable string interpolation for the string."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "dotnet_interactive": {
          "language": "csharp"
        }
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Hello string interpolation!\r\n"
          ]
        }
      ],
      "source": [
        "aFriend = \"string interpolation\";\n",
        "Console.WriteLine($\"Hello {aFriend}!\");"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "You did it! You just created your first C# application and learned about combining strings with string interpolation."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Playground: Try it yourself\n",
        "\n",
        "Each module will have a little \"playground\" at the end. This is a space for you to try writing some code yourself, instead of looking at prewritten code.\n",
        "Try out printing words and variables! Here are some prompts to try:\n",
        "> Print out a personal motto.\n",
        ">\n",
        "> Make some variables with your favorite foods, and then write a little story involving them.\n",
        ">\n",
        "> **Challenge!**\n",
        ">\n",
        "> Make your own Mad Libs! Make a few variables that are verbs, nouns, etcetera, and then use them when you write a story. Have a friend decide the value of each variable and read it to them for a laugh!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "dotnet_interactive": {
          "language": "csharp"
        }
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Playground\r\n"
          ]
        }
      ],
      "source": [
        "Console.WriteLine(\"Playground\");"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Continue learning\n",
        "\n",
        "There are plenty more resources out there to learn!\n",
        ">> [⏩ Next Module - The Basics of Strings](https://raw.githubusercontent.com/dotnet/csharp-notebooks/main/csharp-101/02-The%20Basics%20of%20Strings.ipynb)\n",
        ">\n",
        "> [Watch the video](https://www.youtube.com/watch?v=KT2VR7m19So&list=PLdo4fOcmZ0oVxKLQCHpiUWun7vlJJvUiN&index=2)\n",
        ">\n",
        "> [Documentation: Intro to C#](https://docs.microsoft.com/dotnet/csharp/tour-of-csharp/tutorials/hello-world?WT.mc_id=csharpnotebook-35129-website)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Other resources\n",
        "\n",
        "Here's some more places to explore:\n",
        "> [Other 101 Videos](https://dotnet.microsoft.com/learn/videos?WT.mc_id=csharpnotebook-35129-website)\n",
        ">\n",
        "> [Microsoft Learn](https://docs.microsoft.com/learn/dotnet/?WT.mc_id=csharpnotebook-35129-website)\n",
        ">\n",
        "> [C# Documentation](https://docs.microsoft.com/dotnet/csharp/?WT.mc_id=csharpnotebook-35129-website)"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": ".NET (C#)",
      "language": "C#",
      "name": ".net-csharp"
    },
    "language_info": {
      "file_extension": ".cs",
      "mimetype": "text/x-csharp",
      "name": "C#",
      "pygments_lexer": "csharp",
      "version": "8.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}
